<HTML><HEAD><TITLE>load(++File)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">External Interface</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>load(++File)</H1>
The object code or loadable library File is loaded into the running system.


<DL>
<DT><EM>File</EM></DT>
<DD>Atom or a string.
</DD>
</DL>
<H2>Description</H2>
   Used to load the object code file File into the ECLiPSe system.
   The object code would normally contain functions that implement
   ECLiPSe predicates via the external language interface.
   Such code can currently be written in C or C++.
   See the Embedding and Interfacing Manual for more detail.

<P>
   On modern UNIX systems shared objects are used and loading is done using
   dlopen().  The argument of load/1 must be a shared object (.so file).

<P>
   On Windows systems dynamic libraries are used. The argument of
   load/1 must be a .dll file.

<P>
   For old BSD systems, File specifies one or more object files, libraries
   and/or options in the form accepted by the UNIX linker ld(1).  The
   argument is passed literally to the loader; the command executed is

<P>
<PRE>
   bin/ld -N -A &lt;binary&gt; -T &lt;addr&gt; -o /tmp/eclipse.&lt;pid&gt;.N &lt;File&gt; -lc 1&gt;&amp;2
   2&gt;&amp;2
</PRE>
   where &lt;pid&gt; is the process ID of the ECLiPSe process and N is an integer
   that starts as zero and that is incremented after each dynamic loading.

<P>
   To write portable programs, it is possible to query the value of the
   flag object_suffix. It gives the correct file extensions for the loadable
   objects on the current platform (e.g. "o", "so", "dll").

<P>

<H3>Modes and Determinism</H3><UL>
<LI>load(++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>File is not instantiated.
<DT><EM>(5) type error </EM>
<DD>File is instantiated, but not to an atom or a string.
<DT><EM>(177) problem while trying to load a shared library </EM>
<DD>A shared library object (or one of its dependencies) could not be found
</DL>
<H2>Examples</H2>
<PRE>
Success:

   % See the msg.c example source in external/2.
    % eclipse

   % load the .o file dynamically into the system
    [eclipse]: load('msg.so').
    yes.
    [eclipse]: get_flag(prmsg/1,visibility,Vis).
    accessing an undefined procedure

   % link the object file with a predicate definition.
    [eclipse]: external(prmsg/1,"p_prmsg").
    yes.

   % check on existence and flags of prmsg/1.
    [eclipse]: get_flag(prmsg/1,type,V),
               get_flag(prmsg/1,tool,T),
               get_flag(prmsg/1,visibility,Vis).
    V = user
    T = off
    Vis = local     More? (;)
    yes.

Error:
    [eclipse]: load('msg.c').
    system interface error: Unknown system error
              % not loading an object file.

    [eclipse]: load('msg.o').
    system interface error: No such file or directory
              % no compilation of msg.c to give msg.o

    load(F).                     (Error 4).
    load(msg(o)).                (Error 5).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/externals/call_c-2.html">call_c / 2</A>, <A HREF="../../kernel/externals/external-1.html">external / 1</A>, <A HREF="../../kernel/externals/external-2.html">external / 2</A>, <A HREF="../../kernel/env/get_flag-2.html">get_flag / 2</A>
</BODY></HTML>
